/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package contaspagar.classes;


import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Acer
 */
public class ConsultaContasPagarTableModel extends AbstractTableModel{

   private List<ContasPagar> listaConta;
   private String[] colunas ={"Nº Conta", "Data Emissão", "Cedente", "Data Vencimento", "Valor Pagar"};

    public ConsultaContasPagarTableModel() {
        listaConta = new ArrayList<ContasPagar>();
    }

    public int getRowCount() {
        return listaConta.size();
    }

    public int getColumnCount() {
        return colunas.length;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
         ContasPagar c = listaConta.get(rowIndex);
         if (columnIndex==0){
             return c.getIdConta();
         }else if (columnIndex==1){
             return  c.getDataEmissao();
         }else if (columnIndex==2){
             return c.getCedente();
         }else if (columnIndex==3){
             return c.getDataPagamento();
         }else return c.getValorPagar();
    }

    public  void adiciona(ContasPagar c){
        listaConta.add(c);
    }

    public void adiciona(Collection<ContasPagar> c){
        listaConta.addAll(c);
    }

    @Override
    public String getColumnName(int column) {
        return colunas[column];
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        if (columnIndex==0){
             return Integer.class;
         }else if (columnIndex==1){
             return  Date.class;
         }else if (columnIndex==2){
             return String.class;
         }else if (columnIndex==3){
             return Date.class;
         }else return Double.class;
    }

    public ContasPagar getConta(int linha){
        return  listaConta.get(linha);
    }


}
